import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class GUIPatientInfo extends JPanel {
    
    private JLabel welcome;
    private JPanel center;
    private JPanel panel;
    private JTextField fName;
    private JTextField lName;
    private JTextField address;
    private JButton update;
    private Patient current;

private JTabbedPane jPane;
 
      public GUIPatientInfo(Patient p)
		{

			current = p;

			welcome = new JLabel("Change your information below");
			fName = new JTextField(current.getFirstName());
			lName = new JTextField(current.getLastName());
			address = new JTextField(current.getAddress());
			update = new JButton("Save information");
			center = new JPanel();
			center.setLayout(new BoxLayout(center, BoxLayout.Y_AXIS));
			center.add(fName);
			center.add(lName);
			center.add(address);
			panel = new JPanel();
			panel.setLayout(new BorderLayout());
			panel.add(welcome, BorderLayout.NORTH);
			panel.add(center, BorderLayout.CENTER);
			panel.add(update, BorderLayout.SOUTH);
			
			this.add(panel);
			
			UpdateListener listener = new UpdateListener();
			update.addActionListener(listener);
		}


    private class UpdateListener implements ActionListener
		{
			public void actionPerformed(ActionEvent event)
			{
				String f = fName.getText();
                                String l= lName.getText();
                                String a= address.getText();
				
                               current.setAddress(a);
                               current.setLastName(l);
                               current.setFirstName(f);
                                
                             
			}
		}	
}
